package net.helix;

import org.lwjgl.util.vector.Vector3f;

import net.helix.engine.EngineTop;
import net.helix.physics.Collision;

public class Main {
	public static void main(String args[]){
		// Start helix
		// TODO: make sure only 1 helix window is open at a time?
		// there is an easy trick to use the file system for this.
		
		EngineTop.Start();
		// TODO: if it exited with an error, make it catch the error and display an error popup.
		// TODO: add an option to "save work anyway" when it needs to force quit and lose your progress.
		// Perhaps it's possible to save the file even if it's corrupt. Maybe make it try a few undo's to...
		
		
		/*
		System.out.println(Collision.rayIntersectPlane(new Vector3f(0,0,-2), new Vector3f(0,1,.00001f),
				new Vector3f(0,0,0), new Vector3f(1,0,0), new Vector3f(0,1,0)));
		*/
		
		float[][] cube = new float[8][3];
		cube[0][0] =-1; cube[0][1] =-1; cube[0][2] =-1;
		cube[1][0] =-1; cube[1][1] = 1; cube[1][2] =-1;
		cube[2][0] = 1; cube[2][1] = 1; cube[2][2] =-1;
		cube[3][0] = 1; cube[3][1] =-1; cube[3][2] =-1;
		
		cube[4][0] =-1; cube[4][1] =-1; cube[4][2] = 1;
		cube[5][0] =-1; cube[5][1] = 1; cube[5][2] = 1;
		cube[6][0] = 1; cube[6][1] = 1; cube[6][2] = 1;
		cube[7][0] = 1; cube[7][1] =-1; cube[7][2] = 1;
		
		Collision.rayIntersectCube(new Vector3f(-1.00001f,.5f,.5f), new Vector3f(-.01f,.01f,.01f), cube);
		
		
	}
	public static float subtract(float a, float b) {
		if(a > 0){
			a = Math.max(a-b,0);
		}else{
			a = Math.min(a+b,0);
		}
		return a;
	}
	public static float subtractAngles(float a, float b){
		float ans = b - a;
		while(ans < 180) ans += 360;
		while(ans > 180) ans -= 360;
		return ans;
	}

	
}
